<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>    
<%@ page import="org.swim.entity.User" %>
<%@ page import="org.swim.entity.FriendRequests" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Friends Requests</title>
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
	<%@ include file="NavBar.jsp" %>
	<% 
	boolean areThereFriendRequests = (Boolean) request.getAttribute("areThereFriendRequests");
	User user = (User) session.getAttribute("user"); 
	%>
	<div class="container">
	<h1>Friendship Requests</h1>
	<% if (areThereFriendRequests) { 
		List<FriendRequests> friendRequests = (List<FriendRequests>) request.getAttribute("friendRequests");  
		if(!(friendRequests.size()==0)) {
		for (FriendRequests current: friendRequests) { %>
		<div class="row">
			<div class="span4">
				<div class="media"><a class="pull-left" href="<% out.print("Profile?id="+ current.getMittente().getId());%>">
				<img class="media-object" alt="64x64" style="width: 64px; height: 64px;" src="<% out.print(current.getMittente().getAvatar()); %>" data-src="holder.js/64x64">
				<div class="media-body">		
			    <h4 class="media-heading"><% out.print(current.getMittente().getNome() + " " + current.getMittente().getCognome()); %></h4></div></a></div>
		    </div>
		    <div class="span4">
			    <p>
				 	<a href="ApproveFriendRequest?id=<% out.print(current.getIdRichiesta()); %>"><button class="btn btn-small btn-success" type="button">Approve</button></a>
				  	<a href="DenyFriendRequest?id=<% out.print(current.getIdRichiesta()); %>"><button class="btn btn-small btn-danger" type="button">Deny</button></a>
				</p>
			</div>
	    </div>	
		<% } 			
		} else { %>
		<div class="alert alert-info"><strong>No friendships requests:</strong> there are no friendships requests to approve</div>	
	<% }} else { %>
		<div class="alert alert-info"><strong>No friendships requests:</strong> there are no friendships requests to approve</div>	
	<% } %>	
	</div>
</body>
</html>